<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
 *
 * @package		Adminpro
 * @author		Tran Hoang Thien (thienhb12@gmail.com)
 * @copyright   PHP TEAM
 * @link		http://phpandmysql.net
 * @since		Version 1.0
 * @phone       0944418192
 *
 */
class Category extends MY_Controller {

	public function __construct(){
		parent:: __construct();
		$this->load->model('film_model');
		$this->load->model('page_model');
		$this->load->model('category_model');
		$this->load->model('config_model');
	}

	public function index(){
		$data                      = array();
		$data['config']            = $this->cache_site->get_info_cache($key = 'config',$time = 86400,$this->config_model->get_config_info());
		$data['keywords']          = $data['config']['cf_seo'];
		$data['description']       = $data['config']['cf_meta'];
		$data['phone']             = $data['config']['cf_phone'];
		$data['email']             = $data['config']['cf_email'];
		$data['result_cate']       = $this->cache_site->get_info_cache($key = 'cate',$time = 86400,$this->category_model->get_data_cate());
		$data['page']              = $this->cache_site->get_info_cache($key = 'page',$time = 86400,$this->page_model->get_list_page());
		$url 					   = $this->uri->segment(1);
		$rewrite_cate			   = $this->uri->segment(2);
		$param_cate 			   = array('idcate','namecate','rewrite','nameseocate');
		$cate_where                = array('rewrite'=> $rewrite_cate,'status' => 1);
		$data['cate_rewrite']	   = $this->category_model->get_info_rule($cate_where,$param_cate);
		$data['title']             = $data['cate_rewrite']['nameseocate'];
		$param                     = array();
		$param['select']           = array('idphim','name','content','urlep_new','thumb','hot','decu','rewrite');
		$param['where']            = array('status' => 1);	
		$param['like']			   = array('category'=> $data['cate_rewrite']['idcate']);
		$config['base_url']        = base_url().$url.'/'.$rewrite_cate;
		$config['total_rows']      = $this->film_model->get_total($param);
		$config['per_page']        = $data['config']['cf_numrecord'];
		$config['uri_segment']     = '3';
		$config['first_link']      = '<<';
		$config['last_link']       = '>>';
		$config['first_tag_open']  = '<li class="click">';
		$config['first_tag_close'] = '</li>';
		$config['last_tag_open']   = '<li class="click">';
		$config['last_tag_close']  = '</li>';
		$config['prev_tag_open']   = '<li class="click">';
		$config['prev_tag_close']  = '</li>';
		$config['next_tag_open']   = '<li class="click">';
		$config['next_tag_close']  = '</li>';
		$config['num_tag_open']    = '<li class="click">';
		$config['num_tag_close']   = '</li>';
		$config['next_link']       = 'Next';
		$config['prev_link']       = 'Prev';
		$config['cur_tag_open']    = '<li class="active"><a>';
		$config['cur_tag_close']   = '</a></li>';
		$this->load->library("pagination");
		$this->pagination->initialize($config);
		$start                     = $this->uri->segment(3)?$this->uri->segment(3):0;
		$param['limit']			   = array($config['per_page'] ,$start);
		$data['result']            = $this->film_model->get_list($param);
		$data['template']          = 'category/category';
		$this->load->view("layout",$data);
	}

}

/* End of file index.php */
/* Location: ./application/modules/home/controllers/index.php */